#include<iostream>
#include<stack>
#include<vector>
#include<string>
using namespace std;
const int maxn=32;
int N;
int pre[maxn];
int iin[maxn];
stack<int> treeNode;
vector<int> ans;
struct node{
    int data;
    node* lchild=NULL;
    node* rchild=NULL;
};
node* create(int preL,int preR,int inL,int inR){
    if(preL>preR || inL>inR){return NULL;}
    int k=pre[preL];
    int mid;
    for(int i=inL;i<=inR;i++){
        if(iin[i]==k){
            mid=i;
            break;
        }
    }
    node* root=new node();
    root->data=k;
    root->lchild=create(preL+1,preL+mid-inL,inL,mid-1);
    root->rchild=create(preL+mid-inL+1,preR,mid+1,inR);
    return root;
}
void postorder(node* root){
    if(root==NULL)return;
    postorder(root->lchild);
    postorder(root->rchild);
    ans.push_back(root->data);
}
int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d",&N);
    string action;
    int id;
    int numpre=0,numin=0;
    for(int i=0;i<2*N;i++){
        cin>>action;
        if(action=="Push"){
            scanf("%d",&id);
            pre[numpre++]=id;
            treeNode.push(id);
        }
        else{
            iin[numin++]=treeNode.top();
            treeNode.pop();
        }
    }
    node* root=new node();
    root=create(0,N-1,0,N-1);
    postorder(root);
    for(int i=0;i<ans.size();i++){
        if(i==0)printf("%d",ans[i]);
        else{
            printf(" %d",ans[i]);
        }
    }
    return 0;
}
